Arduino Smart home parking

·

Arduino Smart home parking
Arduino Smart home parking

Smart Home Parking

Build a neat Arduino project that watches your home and parking. In this guide, you get a clear plan, parts list, wiring, code, and test tips. Also, you get a download link for the raw code. Therefore, you can build the system fast. Moreover, you learn how gas detection, environment sensing, and an automated gate work together. For that reason, this project makes a strong final year or IoT beginner build.

Project Overview

This Arduino smart home project blends gas detection, environment monitoring, and automated parking. It uses the Arduino Uno and simple sensors. Thus, you learn wiring, interrupts, and servo control. Also, you get real-time display on an LCD. As a result, you see parking status and sensor readings at a glance.

Key Features

  • Environmental monitoring with DHT11 for temp and humidity.
  • Gas detection that triggers a servo alert.
  • IR sensor for car detection and automatic gate control.
  • LCD display that shows parking status and sensor values.
  • Interrupt-driven gas alarm for fast response.

Why Build This Project

If you want hands-on learning, this project helps. First, it covers sensors, actuators, and displays. Second, it shows interrupts and real-time loops. Third, it fits Arduino Uno well. Therefore, it serves as a strong portfolio piece. Also, it works in home, industry, and parking lot demos. For that reason, you can use it as a final year project or a demo in labs.

Parts and Tools

Gather common parts before you start. Also, choose boards that fit your budget. For instance, ELEGOO kits give a cheap, compatible option. Meanwhile, you can swap sensors with similar models if needed.

Core Parts

  • Arduino Uno board (or compatible board like ELEGOO).
  • DHT11 temperature and humidity sensor.
  • MQ-series gas sensor (or equivalent gas detector).
  • IR obstacle sensor for parking detection.
  • Two small servo motors for gate and gas alert.
  • 16×2 LCD with I2C adapter or direct pins.
  • Breadboard, jumper wires, and power supply.

Optional Parts

  • Raspberry Pi (for advanced logging),
  • WiFi module for remote alerts,
  • LEDs and buzzer for extra alerts.

Arduino Smart home parking System Flow

Start with sensor reads, then check gas and car presence. If gas appears, the code triggers a servo alert and shows a warning. If a car arrives, the gate servo opens briefly and then closes. Also, the LCD updates every second. For this reason, you get live feedback. Meanwhile, the system logs results to serial for debugging.

How Sensors Work

The DHT11 gives temp and humidity. Next, the gas sensor uses an analog or digital pin to flag leaks. Then, the IR sensor shows if a car blocks the spot. Finally, the LCD prints P:X when occupied or P:Y when free. As a result, you always see the current parking status.

Wiring and Connections

Wire parts carefully. First, power the Arduino with a stable 5V supply. Second, attach the LCD and verify contrast. Third, place the DHT11 on a long header to read air. Lastly, mount the IR sensor at the parking spot and aim it to detect a vehicle.

Pin Map (Simple)

  • LCD pins to Arduino digital pins (or I2C if you have the adapter).
  • DHT11 to analog A0.
  • Gas sensor to digital pin 3 (interrupt capable).
  • IR sensor to digital pin 2.
  • Gate servo to A4 (or a PWM pin).
  • Gas alert servo to A3.

Next, check pull-ups and power needs. Also, keep sensor grounds common. For that reason, connect all grounds to the Arduino ground. Meanwhile, avoid powering servos from the Arduino 5V if they draw high current. Instead, use a separate 5V supply that shares ground.

Design Tips

Place the gas sensor away from direct wind. Also, mount the IR sensor around bumper height for cars. Furthermore, make the LCD visible near the gate. That way, users read data easily. In addition, protect electronics from moisture in outdoor setups. For that reason, use a small box and vents for the sensors.

Arduino Smart home parking Code

Below is the main sketch that runs the system. It includes DHT, LCD, servos, and interrupts. Therefore, paste it into your Arduino IDE and upload. Also, you can download the raw file via the link below.

#include <Wire.h> #include <LiquidCrystal.h> #include <Servo.h> #include <DHT.h> // LCD pins LiquidCrystal lcd(13, 12, 11, 10, 9, 8); // Servo motors Servo gateServo; // Gate motor (A4) Servo gasServo; // Gas sensor motor (A3) // DHT11 setup (for humidity) #define DHT_PIN A0 #define DHT_TYPE DHT11 DHT dht(DHT_PIN, DHT_TYPE); // Sensor pins #define GAS_SENSOR_PIN 3 // Pin for gas detection #define IR_SENSOR_PIN 2 // Pin for parking spot (IR sensor) // Flags for interrupt handling volatile bool gasDetected = false; void setup() { // LCD setup lcd.begin(16, 2); lcd.clear(); // Servo motors setup gateServo.attach(A4); gasServo.attach(A3); gateServo.write(0); // Initialize gate servo closed gasServo.write(0); // Initialize gas servo idle // DHT11 setup dht.begin(); // Interrupt setup pinMode(GAS_SENSOR_PIN, INPUT_PULLUP); pinMode(IR_SENSOR_PIN, INPUT); attachInterrupt(digitalPinToInterrupt(GAS_SENSOR_PIN), handleGasDetection, RISING); Serial.begin(9600); } void loop() { // Read temperature and humidity float temperature = dht.readTemperature(); float humidity = dht.readHumidity(); // Handle gas detection if (gasDetected) { gasDetected = false; // Reset flag for (int i = 0; i < 2; i++) { gasServo.write(180); // Rotate 180 degrees delay(1000); gasServo.write(0); // Return to 0 degrees delay(1000); } } // Handle car detection if (digitalRead(IR_SENSOR_PIN) == HIGH) { gateServo.write(90); // Open gate delay(5000); // Keep gate open for 5 seconds gateServo.write(0); // Close gate } // Display parking and environmental data lcd.clear(); lcd.setCursor(0, 0); lcd.print("P:"); lcd.print(digitalRead(IR_SENSOR_PIN) == HIGH ? "X" : "Y"); // Parking spot status lcd.print(" T:"); lcd.print(temperature, 1); // Temperature lcd.print("C"); lcd.setCursor(0, 1); lcd.print("H:"); lcd.print(isnan(humidity) ? "Err" : String(humidity, 1)); // Humidity lcd.print("%"); delay(1000); // Refresh display every second } // ISR for gas detection void handleGasDetection() { gasDetected = true; } 

After you upload, test each sensor one by one. First, test DHT readings. Next, test the IR sensor. Then, trigger the gas interrupt to see the servo motion. Also, monitor the serial output during tests.

How the Code Works

The sketch uses the DHT library to read temp and humidity. Also, it sets up an interrupt on the gas pin for fast alerts. Meanwhile, the loop reads sensors and updates the LCD every second. If gas triggers, the ISR sets a flag and the loop runs the gas servo. In the same way, IR triggers open the gate servo for a short period. Thus, the system stays responsive without blocking reads.

Interrupt Use

Using an interrupt gives instant reaction to gas events. Also, this avoids long polling. Therefore, the gas alarm triggers even if the main loop is busy. As a result, you get a safer and faster reaction.

Servo Control

Servos move the gate and show an alert motion for gas events. Also, move servos in small steps if you want smoother movement. For instance, use gradual angles with delays to avoid jerky motion. Meanwhile, keep an eye on power draw. For that reason, use a separate supply if servos draw high current.

Display and UX

Keep the LCD layout simple. On the first line, show parking status and temp. On the second line, show humidity and short alerts. Therefore, users read info at a glance. Also, update the display every second for live feel. For that reason, avoid heavy prints in the loop that slow the display.

Testing Steps

  1. Power the Arduino and check serial output. Then, verify the LCD boots.
  2. Read DHT11 values and check for stable numbers.
  3. Place your hand near the IR sensor to simulate a car. Next, confirm gate motion.
  4. Simulate gas by waving a small source near the gas sensor. Then, observe the servo motion and alert.
  5. Check for false positives and adjust sensor thresholds if needed.

Common Issues and Fixes

If the DHT returns NaN, check wiring and power. Also, try adding a short delay before reads. If the IR sensor triggers too often, adjust its sensitivity or shield it from ambient light. If servos jitter, give them a stable power supply and add decoupling capacitors. Meanwhile, if the gas sensor reads unstable values, let it warm up for a few minutes and calibrate its threshold.

Applications and Use Cases

Use this system in small private parking lots to track free spots. Also, use it at home for driveway gate control. Furthermore, the gas detection part works well in small workshops and kitchens. If you add a WiFi module, you can send alerts to a phone. For that reason, this project scales from demo to practical use.

Extension Ideas

  • Add WiFi logging and view sensor data on a dashboard.
  • Store readings on an SD card for later analysis.
  • Use a small buzzer and LED for local alerts.
  • Replace the LCD with an OLED for compact builds.
  • Use multiple IR sensors for a small lot with many spots.

Safety Notes

Always test gas sensors in a safe environment. Also, do not rely on this build for critical safety without proper certification. Meanwhile, keep wiring tidy and protect electronics from moisture. For that reason, use enclosures and gaskets when you install outdoors.

Download Code

Download the full sketch and a README from this link. Also, use the file for quick uploads into the Arduino IDE. For your convenience, the code above matches the download file. Therefore, you can copy it directly or use the file download.

Download: smart_home_parking.ino

Suggested FAQ

Q: Can I use a different gas sensor? Yes. However, test its output and adjust code thresholds. In addition, calibrate the sensor for your gas type.

Q: Will this work with Arduino Nano? Yes. Just remap pins and ensure the Nano has enough PWM pins for servos. Also, use a stable 5V supply.

Q: How to avoid false IR triggers? Use shielding and tune the sensor. Also, test at different times of day to ensure stable detection.

Final Notes

This project gives strong hands-on learning. Also, it fits many real-world needs. Therefore, try it and add features as you grow your skills. For example, add remote logging or a web dashboard later. Meanwhile, keep the code modular so you can expand without breaking the core functions. Finally, share your build photos and wiring diagrams to help others copy your project.

Explore More from Embed Electronics Blog

 

HiLetgo ESP-WROOM-32 ESP32 ESP-32S Development Board $9.99

HiLetgo 3pcs ESP32 ESP-32D ESP-32 CP2012 USB-C 38-Pin Dev Board $17.99

ELEGOO UNO R3 Board ATmega328P with USB Cable (Arduino-Compatible) – $13.59

ELEGOO MEGA R3 Board ATmega2560 + USB Cable – $18.39

ELEGOO UNO R3 Board ATmega328P with USB Cable (Arduino-Compatible) – $13.59

ELEGOO MEGA R3 Board ATmega2560 + USB Cable – $18.39

ELEGOO UNO Project Super Starter Kit with Tutorial – $35.99

ELEGOO UNO Project Super Starter Kit with Tutorial – $35.99

Commentaires

Leave a Reply

Discover more from Simple Embedded electronics projects

Subscribe now to keep reading and get access to the full archive.

Continue reading